package com.example.mallcoupon.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.mall.common.Result;
import com.example.mallcoupon.feign.MemberFeignService;
import com.example.mallcoupon.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.reflect.Member;
import java.util.Map;

@RefreshScope
@RestController
@RequestMapping("/coupon")
public class couponController {
	@Value("${nacosConfigTest.name}")
	private String name;
	@Value("${nacosConfigTest.value}")
	private String value;

	@Resource
	MemberFeignService memberFeignService;
	@Autowired
	CouponService couponService;

	@GetMapping("/test")
	public String  test(@RequestHeader(value = "Truth",required = false) String truth){
		String s = memberFeignService.memberFeignTest();
		String result = "这是调用者模块调用 被调用者模块返回接口："+s;
		System.out.println("truth = " + truth);
		return result;
	}


	@GetMapping("/configTest")
	public String configTest(){
		return "获取的值："+name+":"+value;
	}



	@GetMapping("/query")
	public String query(){
		couponService.query1();
		return "成功";
	}

	@GetMapping("/save")
	public String save(){
		couponService.query1();
		return "成功";
	}

	@SentinelResource("hot")
	@GetMapping("/hot")
	public String hot(@RequestParam String id){
		System.out.println("热点参数");
		return "成功";
	}


	@GetMapping("XA-TransTest")
	public String XA(){
		 couponService.saveAll();
		return "成功0";
	}
}
